<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<jsp:include page="head.jsp" />
<link rel="stylesheet" type="text/css" href="${path}/css/monitor-alarm.min.css?" />
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<div id="content">
	<div id="content-header">
		<div id="breadcrumb">
			<a href="main" title="Go to Home" class="tip-bottom"><i
				class="icon-home"></i> Home</a> <a href="#" class="current">Alarm Rules</a>
		</div>
		<c:if test="${not empty return_msg}">
		   <c:if test="${result == 'success'}">
		     <div class="alert alert-success alert-block"> <a class="close" data-dismiss="alert" href="#">×</a>
               <h4 class="alert-heading"><c:out value="${result}"></c:out>!</h4> <c:out value="${return_msg}"></c:out>.
             </div>
		   </c:if>
		   <c:if test="${result == 'fail'}">
		     <div class="alert alert-error alert-block"> <a class="close" data-dismiss="alert" href="#">×</a>
                <h4 class="alert-heading"><c:out value="${result}"></c:out>!</h4> <c:out value="${return_msg}"></c:out>.
              </div>
		   </c:if>
        </c:if>
	</div>
	<div class="container-fluid">
		<div class="row-fluid">
			<div class="span12">
				<div class="widget-box">
					<div class="widget-title">
						<span class="icon"><i class="icon-th"></i></span>
						<div class="buttons">
							&nbsp;<a href="alarmAction" class="btn btn-inverse btn-mini">
							<i class="icon-plus icon-white"></i>Add Alarm Rules</a>
						</div>
					</div>
					<div class="widget-content nopadding">
						<table class="table table-bordered data-table">
							<thead>
								<tr>
									<th>应用名称</th>
									<th>监控类型</th>
									<th>监控项名称</th>
									<th>报警名称</th>
									<th>报警级别</th>
									<th>报警间隔</th>
									<th>报警内容</th>
									<th>报警状态</th>
									<th>创建时间</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
								<c:forEach items="${items}" var="item">
									<tr>
										<td align="center">${item.appName}</td>
										<td>${item.pluginName}</td>
										<td>${item.itemName}</td>
										<td>${item.alarmName}</td>
										<td>${item.alarmLevel}</td>
										<td>${item.alarmInterval}</td>
										<td>${item.alarmRules}</td>
										<td>
										     <c:choose>
												<c:when test="${item.alarmStatus == 'on'}">
													<span class="badge badge-success">${item.alarmStatus}</span>
												</c:when>
												<c:when test="${item.alarmStatus == 'off'}">
													<span class="badge badge-warning">${item.alarmStatus}</span>
												</c:when>
												<c:otherwise>
													${item.alarmStatus}
												</c:otherwise>
											</c:choose>
										</td>
										<td><fmt:formatDate value="${item.createTime}" type="both"/></td>
										<td>
											<div class="btn-group">
									           <button data-toggle="dropdown" class="btn btn-success dropdown-toggle">Actions <span class="caret"></span></button>
									           <ul class="dropdown-menu">
										         <c:choose>
													<c:when test="${item.alarmStatus == 'on'}">
														<li><a href="changeStatusAlarm?id=${item.id}&alarmStatus=off"><i class="icon-ban-circle"></i> OFF</a></li>
													</c:when>
													<c:when test="${item.alarmStatus == 'off'}">
														<li><a href="changeStatusAlarm?id=${item.id}&alarmStatus=on"><i class="icon-ok-circle"></i> ON</a></li>
													</c:when>
													<c:otherwise>
														&nbsp;
													</c:otherwise>
											    </c:choose>
												<li><a href="alarmAction?id=${item.id}"><i class="icon-pencil"></i> Edit</a></li>
												<li><a href="deleteAlarm?id=${item.id}"><i class="icon-trash"></i> Delete</a></li>
									         </ul>
									       </div>
										</td>
									</tr>
								</c:forEach>
							</tbody>
						</table>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<jsp:include page="footer.jsp" />
<script src="${path}/js/monitor-alarm.min.js"></script>
</body>
</html>